package Thread.Demo13Syn;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @Author wangzhipeng
 * @Date 2020-08-21 3:59 下午
 * @Description 测试JUC安全类的集合
 */
public class TestJUC {
    public static void main(String[] args) {
       // CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<>();
        List<String> list = new ArrayList<>();
        for(int i = 0;i < 1000;i++){
            new Thread(()->{
                list.add(Thread.currentThread().getName());
            }).start();
        }

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(list.size());


    }

}
